﻿<%@ Control Language="C#" AutoEventWireup="true" CodeFile="messageList.ascx.cs" Inherits="VISS.Web.Frontend.Modules.User.Profile.MessagesListControl" %>

<%@ Import Namespace="VISS.API.Users" %>
<%@ Import Namespace="NCT.Framework" %>

<% if (MessageResult.Count > 0) {
       for (int i = 0; i < MessageResult.Count; i++) { %>
        <div class="message-box <% if (MessageResult[i].Status == EUserMessageStatus.UnRead) Response.Write("unread"); %>" >
            <!--avatar-->
            <div class="left">
                <div class="avatar">
                    <a href="<%=AppSettings.RootURL %>profile?u=<%=MessageResult[i].SentUserKey %>"><img src="<%=VISS.Web.Frontend.AvatarUtils.GetAvatarThumbPath(MessageResult[i].SenderAvatarFileName, MessageResult[i].SenderAvatarImageStoreID, MessageResult[i].SenderGender, MessageResult[i].SenderAvatarStatus) %>" /></a>
                </div>
                <div class="border"></div>
            </div>
            <!--content-->
            <div class="middle">
                <div class="top">
                    <div class="name">
                        <a href="<%=AppSettings.RootURL %>profile?u=<%=MessageResult[i].SentUserKey %>" title="Xem thông tin của <%=MessageResult[i].SenderName %>"><%=MessageResult[i].SenderName%></a>
                    </div>
                    <div class="title">
                        <a href="<%=AppSettings.RootURL %>profile/conversation?cid=<%=MessageResult[i].ConversationID %>" title="Xem cuộc hội thoại"><%=VISS.Web.Frontend.Commons.HtmlCharEncode(StringUtils.CutStringChar(MessageResult[i].Title, 30))%></a>
                    </div>
                    <div class="time">
                        <span class="timeago" title="<%=MessageResult[i].DateCreated %>"></span>
                    </div>
                </div>
                <div class="bottom">
                    <a href="<%=AppSettings.RootURL %>profile/conversation?cid=<%=MessageResult[i].ConversationID %>" title="Xem cuộc hội thoại">
                        <% 
                           int index = MessageResult[i].Content.IndexOf("<br />", 0);
                           if (index < 0) {
                               Response.Write(StringUtils.CutStringChar(MessageResult[i].Content, 70));
                           }
                           else {
                               string shortContent = MessageResult[i].Content.Substring(0, index);
                               Response.Write(StringUtils.CutStringChar(shortContent, 70));
                           }
                        %>
                    </a></div>
            </div>
            <div class="right">
                <div class="reply-conversation-link">
                    <a href="<%=AppSettings.RootURL %>profile/conversation?cid=<%=MessageResult[i].ConversationID %>" title="Trả lời tin nhắn">
                        <div class="reply-conversation reply-conversation-off"></div>
                    </a>
                </div>
                <input name="btnDeleteConversation" type="button" class="delete-conversation delete-conversation-off" onclick="DeleteConversation('<%=MessageResult[i].ConversationID %>');" title="Xóa cuộc hội thoại này" />
            </div>
        </div>
<%      }
   } else { %>
        <div class="empty-page">Bạn không có tin nhắn nào trong trang này</div>     
<% } %>